<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="layim/css/layui.css">

	</head>

	<body>
		<h1 class="tit">heyang</h1>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="layim/layui.js" type="text/javascript" charset="utf-8"></script>
		
		<script>
			layui.use('layim', function(layim) {

				layim.config({
					//初始化接口
					init: {
						type:'get',
						url: 'http://localhost/tpProject/backCms/public/index/index/user'
						
					}

				});

				var ws = new WebSocket("ws://127.0.0.1:1234");
				var name = $(".tit").text();
				console.log(name)
				ws.onopen = function() {
					//发送登录信息
					var data = '{"type":"login","name":"' + name + '"}';
					ws.send(data);
				};
				ws.onmessage = onmessage;

				function onmessage(e) {
					//var data = eval("(" + e.data + ")");
					var data = e.data;
					//显示
					console.log(data)
					//					var show = document.getElementById("show");
					//					show.innerHTML += data + "<br>";
				}

				//先来个客服模式压压精
				layim.config({
					brief: true //是否简约模式（如果true则不显示主面板）
				}).chat({
					name: '聊天室',
					type: 'friend',
					avatar: 'http://tp1.sinaimg.cn/5619439268/180/40030060651/1',
					id: -2
				});
			});
		</script>
	</body>

</html>